#ifndef MINUTE_TIMER_H
#define MINUTE_TIMER_H

#include <singleton.h>

class CTimerSubscriber
{
public:
    virtual ~CTimerSubscriber(){}

    virtual void OnTrigger(time_t) = 0;
};

class CTimer
{
    typedef std::set<CTimerSubscriber *> TSubscribers;
public:
    virtual ~CTimer(){}
    // subscribe the trigger event
    void Subscribe(CTimerSubscriber * pSubscriber);
    // un-subscribe
    void UnSubscribe(CTimerSubscriber * pSubscriber);
    // notify all the subscriber
    void NotifyAll();
private:
    TSubscribers m_Subscribers;
};

class CSecondTimer : public CSingleton<CSecondTimer>, public CTimer
{
    friend class CSingleton<CSecondTimer>;
};

class CMinuteTimer : public CSingleton<CMinuteTimer>, public CTimer
{
    friend class CSingleton<CMinuteTimer>;
};

#endif // endif of MINUTE_TIMER_H
